import type { RouteRecordName } from "vue-router";
import type SSEClient from "@/utils/sse";

export type cacheType = {
  mode: string;
  name?: RouteRecordName;
};

export type positionType = {
  startIndex?: number;
  length?: number;
};

export type appType = {
  sidebar: {
    opened: boolean;
    withoutAnimation: boolean;
    // 判断是否手动点击Collapse
    isClickCollapse: boolean;
  };
  layout: string;
  device: string;
  viewportSize: { width: number; height: number };
  sortSwap: boolean;
  visitorId: string;
};

export type multiType = {
  path: string;
  name: string;
  meta: any;
  query?: object;
  params?: object;
};

export type setType = {
  title: string;
  fixedHeader: boolean;
  hiddenSideBar: boolean;
};

export type userType = {
  avatar?: string;
  userName?: string;
  nickName?: string;
  roles?: Array<string>;
  permissions?: Array<string>;
  verifyCode?: string;
  currentPage?: number;
  isRemembered?: boolean;
  loginDay?: number;
};

export type LoginTokenResult = {
  /** 头像 */
  avatar: string;
  /** 用户名 */
  userName: string;
  /** 昵称 */
  nickName: string;
  /** 当前登录用户的角色 */
  roles: Array<string>;
  /** 按钮级别权限 */
  permissions: Array<string>;
  /** 会话ID */
  connectSid: string;
  /** `token` */
  accessToken: string;
  /** 用于调用刷新`accessToken`的接口时所需的`token` */
  refreshToken: string;
  /** `accessToken`的过期时间（格式'xxxx/xx/xx xx:xx:xx'） */
  expires: number;
};

export type userInfoType = {
  /** 头像 */
  avatar: string;
  /** 用户名 */
  userName: string;
  /** 昵称 */
  nickName: string;
  /** 邮箱 */
  email: string;
  /** 联系电话 */
  phone: string;
  /** 简介 */
  description: string;
};

export type SseTpye = {
  /** 会话实例 */
  seeClient: SSEClient | null;
};

export type FileType = {
  id: string;
  /** 文件名称 */
  name: string;
  /** 文件后缀 */
  ext: string;
  /** 文件类型 */
  mimetype: string;
  /** 文件大小 */
  size: number;
  /** 文件路径 */
  path: string;
  /** 文件访问地址 */
  url: string;
  /** 文件下载地址 */
  download: string;
};

export type UploadFileResult = {
  data: FileType;
  message?: string;
  meta: { msg: string; status: number };
};
